package com.comtime.smartbox;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;


public class BaseActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) { 
		super.onCreate(savedInstanceState);
		hide(getWindow().getDecorView());
	}
	public static void hide(View decorView) {
		if (!hasSmartBar())
			return;

		try {
			@SuppressWarnings("rawtypes")
			Class[] arrayOfClass = new Class[1];
			arrayOfClass[0] = Integer.TYPE;
			Method localMethod = View.class.getMethod("setSystemUiVisibility",
					arrayOfClass);
			Field localField = View.class
					.getField("SYSTEM_UI_FLAG_HIDE_NAVIGATION");
			Object[] arrayOfObject = new Object[1];
			try {
				arrayOfObject[0] = localField.get(null);
			} catch (Exception e) {

			}
			localMethod.invoke(decorView, arrayOfObject);
			return;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 新型号可用反射调用Build.hasSmartBar()来判断有无SmartBar
	 * 
	 * @return
	 */
	public static boolean hasSmartBar() {
		try {
			Method method = Class.forName("android.os.Build").getMethod(
					"hasSmartBar");
			return ((Boolean) method.invoke(null)).booleanValue();
		} catch (Exception e) {
		}

		String string=	android.os.Build.FINGERPRINT.toLowerCase();
		
		if (string.contains("meizu") || string.contains("flm")) {
			return true;
		} else if (Build.DEVICE.equals("mx") || Build.DEVICE.equals("m9")) {
			return false;
		}
		return false;
	}

}
